package com.example.utils;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.Arrays;
/**
 * 微信服务器请求验证
 * @author user
 *
 */
public class CheckUtil {
	private static String token = "ljl152";
	public static boolean checkSignature(String signature, String timestamp, String nonce) {
		String[] arr = new String[] {token,timestamp,nonce};
		//排序
		Arrays.sort(arr);
		
		//生成字符串
		StringBuffer content = new StringBuffer();
		for(int i =0;i<arr.length;i++) {
			content.append(arr[i]);
		}
		
		//sha1加密
		String temp = DigestUtils.sha1Hex(content.toString());
		
		return temp.equals(signature);
		
		
	}
}
